  /**
   * @param {number} target
   * @param {number[]} nums
   * @return {number}
   */
  var minSubArrayLen = function (target, nums) {
    let sum = 0
    if (nums.length <= 1) {
      return (nums[0] && nums[0] <= target) ? 0 : 1
    }
    let len = Infinity
    let p = 0, q = 0
    for (; q < nums.length; q++) {
      sum += nums[q]
      if (sum >= target) {
        while (sum >= target) {
          len = Math.min(len, q - p + 1)
          sum -= nums[p]
          p++
        }
      }

    }
    return Infinity === len ? 0 : len
  };
console.log(minSubArrayLen(7, [2, 3, 1, 2, 4, 3]))
